package jxl;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableHyperlink;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

public class CreateA {

	public static void main(String[] args) {
		List ls = new ArrayList();// 报表名称列表
		ls.add("BB_BB03");
		ls.add("BB_BB05");
		ls.add("BB_BB06");

		try {
			WritableWorkbook wb = Workbook.createWorkbook(new File("D:/python/t1.xls"));
			WritableSheet ws1 = wb.createSheet("BB", 1);// 先建立后面的sheet最后再处理目录的sheet
			WritableSheet ws = wb.createSheet("目录", 0);
			WritableFont wfc = new WritableFont(WritableFont.TIMES, 18, WritableFont.BOLD, true);
			WritableCellFormat wcfFC = new WritableCellFormat(wfc);
			Label lb = new Label(0, 0, "目录", wcfFC);// 标题要字体
			ws.addCell(lb);
			for (int i = 0; i < ls.size(); i++) {
				ws.addHyperlink(new WritableHyperlink(1, i + 1, ls.get(i).toString(), ws1, 0, 0)); // 关键的建立后面sheet连接的一句
			}
			wb.write();
			wb.close();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
